import * as TYPES from '../action-types';

let INIT_STATE = {
    baseInfo: null,
    isLogin: false
};
export default function person(state = INIT_STATE, action) {
    state = JSON.parse(JSON.stringify(state));
    let payload = {};
    switch (action.type) {
        case TYPES.PERSON_QUERY_BASE:
            payload = action.payload;
            if(parseFloat(payload.code) === 0){
                state.baseInfo = payload.data;
            } else {
                state.baseInfo = null;
            }
            break;
        case TYPES.PERSON_LOG_IN:
            payload = action.payload;
            if(parseFloat(payload.code) === 0){
                state.isLogin = true;
            }
            break;
        case TYPES.PERSON_LOG_OUT:
            payload = action.payload;
            if(parseFloat(payload.code) === 0){
                state.isLogin = false;
            }
            break;
    }
    return state;
};